<template>
  <a-spin :spinning="confirmLoading">
    <a-form-model ref="form" :model="models" :rules="validatorRules">
      <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="oldLanguage" required>
        <j-dict-select-tag placeholder="选择语言" dictCode="language_ez" v-model="models.oldLanguage" />
      </a-form-model-item>
      <div class="midICon">
        <i class="iconfont icon-xinyonghucha"></i>
      </div>

      <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="newLanguage" required>
        <j-dict-select-tag placeholder="选择语言" dictCode="language_ez" v-model="models.newLanguage" />
      </a-form-model-item>
    </a-form-model>
  </a-spin>
</template>

<script>
export default {
  name: 'TransLate',
  components: {},
  props: {
    model: {
      type: Object,
      default: {},
    },
    content: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      models: this.model,
      confirmLoading: false,
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 12 },
      },
      validatorRules: {
        newLanguage: [{ required: true, message: '请选择语言' }],
        oldLanguage: [{ required: true, message: '请选择语言' }],
      },
    }
  },
  computed: {
    models1() {
      return this.models
    },
  },
  watch: {
    models1: {
      handler(newVal, oldVal) {
        this.$nextTick(function () {
          // this.model.languageZh = '中文'
          // this.model.languageEh = '英语'

          if (!newVal.newLanguage) {
            //只需判断一个即可
            this.$set(this.model, 'newLanguage', '英语')
            this.$set(this.model, 'oldLanguage', '中文 ')
            console.log('newVal + oldVal', newVal, oldVal, this.model)
          }
        })
      },
      deep: true,
      immediate: true,
    },
  },
  created() {},
  mounted() {},
  methods: {
    generatedBtnProp() {
      let obj = {
        newLanguage: this.models.newLanguage,
        oldLanguage: this.models.oldLanguage,
      }
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.$emit('appApiAsk', 1, obj)
        } else {
          this.$emit('appApiAsk', 2, obj)
        }
      })
    },
  },
}
</script>

<style lang="less">
</style>